<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>

<script type="text/javascript" src="js/utils/json2.js"></script>
<script type="text/javascript">

  function test_save_json() {
    var myJSONObject = {"level": [
        {"name": "To California", 
        "destination": "los angeles, ca", 
        "origins": ["chicago, il", "new orleans, la"]},

        {"name": "USP", 
        "destination": "Praca da Reitoria, Sao Paulo 05508-010", 
        "origins": ["Av. Prof. Luciano Gualberto, 515 - Sao Paulo, SP"]},
        ]
    };
    window.open( "data:text/json;charset=utf-8," + escape(JSON.stringify(myJSONObject)))
  }

  function Level(name, origins, destination, life) {
    this.name = name;
    this.origins = origins;
    this.destination = destination;  // cicles to recover 10% of life
    this.life = life;
  };

  function test_storage() {
      //localStorage.setItem('fullname', 'John Paul');               // defining the localStorage variable 
      //alert("Your name is: " + localStorage.getItem('fullname'));  // accessing it 
      //alert("Hello " + localStorage.fullname);                     // another way of accessing the variable 
      //localStorage.removeItem('fullname');                         // finally unset it  


      var testObject = {"levels": [
          {"name": "To California", 
          "destination": {"lat":36.75649, "lng":-118.88855}, 
          "origins": [{"lat":46.826845, "lng":-100.815353}, {"lat":35.960223, "lng":-91.494141}],
          "initialMoney": 100,
          "enemyProportions": [0.2,0.3,0.5],
          "maxLife":15,
          "numberOfEnemies":30},
  
        ]
      };

      // Put the object into storage
      localStorage.setItem('db', JSON.stringify(testObject));
      
      // Retrieve the object from storage
      var retrievedObject = localStorage.getItem('db');
      
      console.log('retrievedObject: ', JSON.parse(retrievedObject));

  }


    


</script>

</head>
<body onload="test_storage()">
</body>
</html>

